import java.util.Arrays;
import java.util.Scanner;

public class note7 {


    //1.递归求N的阶乘
   /* public static int factorial(int n){
        if(n==1){
            return 1;
        }
        return n*factorial(n-1);
    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n= scan.nextInt();
        System.out.println(factorial(n));
    }*/


    //2.递归求1+2+3……+n；
   /* public static int sum(int n){
        if(n==1){
            return 1;
        }
        return n+sum(n-1);
    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        System.out.println(sum(n));
    }*/


    //3.按顺序打印一个数字的每一位(例如 1234 打印出 1 2 3 4)    （递归）
 /*   public static void printeve(int n){
        if(n<10){
            System.out.print(n+" ");
        }
        //else {
            printeve(n / 10);
            System.out.print(n % 10 + " ");
        //}


    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        printeve(n);
    }
}
*/


//4.拷贝数组
/*    public static void main(String[] args) {

        *//*System.out.println("拷贝前：");
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.toString(arr2));

        for(int i=0;i<arr1.length;i++){
            arr2[i]=arr1[i];
        }
        System.out.println("拷贝后：");
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.toString(arr2));
        arr2[0]=99;*//*
        int[] arr1={1,2,3,4,5};
        int[] arr2=Arrays.copyOf(arr1,arr1.length);
        System.out.println("修改后：");
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.toString(arr2));
        //如果想要拷贝一部分，用Arrays.copyOfRange函数
        int[] arr3=Arrays.copyOfRange(arr1,2,4);//[2,4)左闭右开
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.toString(arr3));*/
    //}



    //5.二分查找
    //冒泡排序
/*    public static void mysort(int[] arr){
        int i=0;
        int j=0;
        int temp=0;
        for(i=1;i<arr.length;i++){
            int flag=0;
            for(j=0;j<arr.length-i;j++){
                if(arr[j]>arr[j+1]){
                    temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                    flag=1;
                }
            }
            if(flag==0){
                break;
            }
        }
    }
    public static void main(String[] args) {
        int[] arr={1,2,3,4,8,9,11,23,34,21,66,56,444};
        mysort(arr);

        System.out.println(Arrays.toString(arr));*/
        /*Arrays.sort(arr);
        System.out.println("排序后数组："+Arrays.toString(arr));
        int k=3;
        int ret=Arrays.binarySearch(arr,88);
        System.out.println(ret);*/
    //}



    //6.数组逆置
 /*   public static void reverse(int[] arr){
        int i=0;*//*
        int j=arr.length-1;
        while(i<j){
            int t=arr[i];
            arr[i]=arr[j];
            arr[j]=t;
            i++;
            j--;
        }
    }
    public static void main(String[] args) {
        int[] arr={1,0,3,88,5,4};
        reverse(arr);
        System.out.println(Arrays.toString(arr));
    }*/


    //初始化二维数组
/*    public static void main(String[] args) {
        int[][] arr={{1,2,3},{4,5,6}};
        int[][] arr2=new int[2][3];
        int[][] arr3=new int[][]{{1,2,3},{4,5,6}};


        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr.length);
        System.out.println(arr[0].length);
    }*/

    //7.for-each打印二维数组

/*    public static void main(String[] args) {
        int[][] arr={{1,2,3},{4,5,6}};
        for(int[] a:arr){
            for(int x:a){
                System.out.print(x+" ");
            }
        }
        System.out.println();
        System.out.println(Arrays.deepToString(arr));
    }*/



    //8.不规则二维数组
 /*   public static void main(String[] args) {
        int[][] arr=new int[2][];
        arr[0]=new int[3];
        arr[1]=new int[5];
        for(int x=0;x<arr.length;x++){
            for(int y=0;y<arr[x].length;y++){
                System.out.print(arr[x][y]+" ");
            }
            System.out.println();
        }

    }*/



    //9.判断两个数组的元素是否相同
/*    public static void main(String[] args) {
        int[] arr={1,2,3,4};
        int[] arr2={1,2,3,4};
        Boolean ret=Arrays.equals(arr,arr2);
        System.out.println(ret);
    }*/


    //10.把数组的部分连续元素置为某值
    public static void main(String[] args) {
        int[] arr=new int[10];
        Arrays.fill(arr,3,6,-1);//左开右闭：[3,6)
        System.out.println(Arrays.toString(arr));
    }
}
